package com.hspedu.newData.dmsxl.哈希表;

import java.util.HashSet;
import java.util.Set;

/**
 * @Author: yh
 * @description: 
 * @CreateTime: 2025-04-29 
 * @Version: 1.0
 */

public class LC287寻找重复数 {

    public int findDuplicate(int[] nums) {

        Set<Integer> set = new HashSet<>();

        for (int i = 0; i < nums.length; i++) {
            if (set.contains(nums[i])){
                return nums[i];
            }
            set.add(nums[i]);
        }

        return 0;
    }

}
